package com.youlu.campus.admin.recycle.controller;

import com.alibaba.fastjson.JSON;
import com.youlu.campus.entity.recycle.dto.RecycleItemSearchDTO;
import com.youlu.campus.service.recycle.service.RecycleItemInfoService;
import com.youlu.campus.entity.recycle.RecycleItemInfo;
import com.youlu.campus.entity.recycle.dto.RecycleItemSaveDTO;
import com.yuelin.infrastructure.quantum.common.QResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 回收商品信息
 * @author : [dengbo]
 * @className : RecycleItemInfoController
 * @description : [回收商品控制器]
 * @createTime : [2022/6/22 17:34]
 */
@Slf4j
@RestController
public class RecycleItemInfoController {
    @Resource
    private RecycleItemInfoService recycleItemInfoService;

    /**
     * 回收商品列表
     * @param request
     * @return
     */
    @PostMapping("/recycle/item/save")
    public QResult save(@Validated @RequestBody RecycleItemSaveDTO request) {
        log.info("RecycleItemInfoController,save,request param:{}", JSON.toJSONString(request));
        RecycleItemInfo data = recycleItemInfoService.save(request);
        return QResult.success(data);
    }

    /**
     * 课程列表
     * @param request
     * @return
     */
    @PostMapping("/recycle/item/search")
    public QResult search(@Validated @RequestBody RecycleItemSearchDTO request) {
        log.info("RecycleItemInfoController,search,request param:{}", JSON.toJSONString(request));
        Page<RecycleItemInfo> data = recycleItemInfoService.search(request);
        return QResult.success(data);
    }
}
